package com.android.place360.place_search_result;

import java.util.Date;

import com.android.place360.R;
import com.android.place360.place_detail.DetailRequest;
import com.android.place360.place_detail.DetailResponse;
import com.android.place360.place_detail.DetailResult;

import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;

public class PullTasksThread extends Thread {
	Context context;
	String reference;
	Handler handler;
	DetailResult detailResult;

	public PullTasksThread(Context context, String reference, Handler handler,
			DetailResult detailResult) {
		super();
		this.context = context;
		this.reference = reference;
		this.handler = handler;
		this.detailResult = detailResult;

	}

	public void run() {
		Looper.prepare();
		DetailRequest detailRequest = new DetailRequest();
		detailRequest.setKey(context.getString(R.string.google_place_api_key));
		detailRequest.setLanguage("vi");
		detailRequest.setReference(reference);
		detailRequest.setSensor(true);
		DetailResponse detail = detailRequest.getResponse();
		Log.i("place360", "END " + String.valueOf(new Date().getSeconds()));
		this.detailResult = detail.getResult();
		handler.sendEmptyMessage(PlaceResultActivity.MSG_PLACE_DETAIL);
		Looper.loop();
	}
}
